package com.rainng.coursesystem.controller;

import com.rainng.coursesystem.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/comments")
public class CommentController {

    @Autowired
    private CommentService commentService;

    // 获取特定帖子下的评论
    @GetMapping
    public List<Map<String, Object>> getComments(@RequestParam int postId) {
        return commentService.getCommentsByPostId(postId);
    }

    // 添加评论
    @PostMapping
    public String addComment(@RequestParam int postId,
                             @RequestParam int studentId,
                             @RequestParam String content) {
        return commentService.addComment(postId, studentId, content);
    }

    // 删除评论
    @PostMapping("/delete")
    public String deleteComment(@RequestParam int commentId) {
        return commentService.deleteComment(commentId);
    }



}
